package com.zmj.sy.mom.srv.aps.controller;

import com.zmj.sy.mom.srv.aps.bean.vo.base.BaseIdReqVo;
import com.zmj.sy.mom.srv.aps.bean.vo.base.BaseResVo;
import com.zmj.sy.mom.srv.aps.bean.vo.base.CommonPage;
import com.zmj.sy.mom.srv.aps.bean.vo.base.Result;
import com.zmj.sy.mom.srv.aps.bean.vo.partexcept.*;
import com.zmj.sy.mom.srv.aps.bean.vo.partexceptdetail.PartExceptDetailAddReqVo;
import com.zmj.sy.mom.srv.aps.config.AspectLog;
import com.zmj.sy.mom.srv.aps.service.PartExceptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RequiredArgsConstructor
@Api(tags = "零件-异常")
@RestController
@RequestMapping("/partExcept")
public class PartExceptController {

    private final PartExceptService partExceptService;

    @ApiOperation("新增零件异常")
    @PostMapping("/createPartExcept")
    public Result createPartExcept(@RequestBody PartExceptReqVo reqVo){
        partExceptService.createPartExcept(reqVo.getConstructNo(),reqVo.getPlmId(),reqVo.getPrePhaseCode(),reqVo.getPhaseCode(),reqVo.getPhaseSeq(),
                reqVo.getExceptCount(), reqVo.getUserCode(),null, reqVo.getGroupCode(), reqVo.getStationCode(), reqVo.getPlateCode());
        return Result.success("新增零件异常成功");
    }

    @ApiOperation("异常报告列表")
    @GetMapping("/list")
    public Result<CommonPage<PartExceptPageResVo>> list(PartExceptPageReqVo reqVo){
        return Result.success(partExceptService.list(reqVo));
    }
    @ApiOperation("异常件详情")
    @GetMapping("/getExceptDetail")
    public Result<PartExceptDetailResVo> getExceptDetail(PartExceptDetailReqVo reqVo){
        return Result.success(partExceptService.getExceptDetail(reqVo));
    }

    @ApiOperation("判定异常件")
    @PostMapping("/addDetail")
    public Result addDetail(@RequestBody PartExceptDetailAddReqVo reqVo){
        partExceptService.addDetail(reqVo);
        return Result.success("判定异常件成功");
    }
    @ApiOperation("删除异常件")
    @PostMapping("/delete")
    @AspectLog(apiName = "删除异常件", operationType = 4)
    public Result delete(BaseIdReqVo reqVo){
        partExceptService.delete(reqVo);
        return Result.success("删除异常件");
    }
    @ApiOperation("确认返修成功")
    @PostMapping("/partCheck")
    @AspectLog(apiName = "确认返修成功", operationType = 4)
    public Result partCheck(@RequestBody PartCheckReqVo reqVo){
        partExceptService.partCheck(reqVo);
        return  Result.success("确认返修成功");
    }

/*    @ApiOperation("批量生成异常零件")
    @PostMapping("/partExceAll")
    public BaseResVo partExceAll(){
        partExceptService.partExceAll();
        return BaseResVo.ok();
    }*/

    @ApiOperation("单个生成异常零件")
    @PostMapping("/partExceOne")
    public BaseResVo partExceOne( Integer id){
        partExceptService.partExceOne(id);
        return BaseResVo.ok();
    }

}
